using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ManagementClinic.Data.Models.Mapping
{
    public class USERS_FUNCTIONSMap : EntityTypeConfiguration<USERS_FUNCTIONS>
    {
        public USERS_FUNCTIONSMap()
        {
            // Primary Key
            this.HasKey(t => t.ID);

            // Properties
            this.Property(t => t.GHI_CHU)
                .HasMaxLength(100);

            // Table & Column Mappings
            this.ToTable("USERS_FUNCTIONS");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.ID_USERS).HasColumnName("ID_USERS");
            this.Property(t => t.ID_FUNCTIONS).HasColumnName("ID_FUNCTIONS");
            this.Property(t => t.GHI_CHU).HasColumnName("GHI_CHU");

            // Relationships
            this.HasRequired(t => t.FUNCTION)
                .WithMany(t => t.USERS_FUNCTIONS)
                .HasForeignKey(d => d.ID_FUNCTIONS);
            this.HasRequired(t => t.USER)
                .WithMany(t => t.USERS_FUNCTIONS)
                .HasForeignKey(d => d.ID_USERS);

        }
    }
}
